package org.arl.modem.transportARQ;

import java.util.ArrayList;
import java.util.List;

public class Block {
   private int blockID;
   private List<Packet> packets;

   private int packetID = 0;

   public Block(int blockID, List<Packet> packets) {
      super();
      this.blockID = blockID;
      this.packets = packets;
      for (Packet p : packets) {
         packetID++;
         p.setBlockPacketId(packetID);
      }
   }

   public int getBlockID() {
      return blockID;
   }

   public void setBlockID(int blockID) {
      this.blockID = blockID;
   }

   public List<Packet> getPackets() {
      return packets;
   }

   public void setPackets(List<Packet> packets) {
      this.packets = packets;
   }

   public Block clone() {
      List<Packet> pktList = new ArrayList<Packet>();
      for (Packet p : this.packets) {
         pktList.add(new Packet(p));
      }

      Block b = new Block(this.blockID, pktList);
      return b;
   }

}
